<template>
	<div id="mains">
		<!--爱车车型选择-->
		<div class="changeCar" @click="checkCar">
			<p id="selectCar">
				<span class="showCars">{{showTypeCar}}</span>
				<i>{{chooses}}</i>
			</p>
		</div>
		
		<!--我要询价，询价单，订单，收藏模块-->
		<MainNav :mes = "mes"></MainNav>
		<!--热销精品-->
		<MainBlock :hot = "hot" :title = "title1"></MainBlock>
		<!--保养用品-->
		<MainBlock :hot = "tenance" :title = "title2"></MainBlock>
		<!--商用车配件-->
		<div class="block goods">
			<h3 style="text-align: center; text-indent: 0;">
				<a>商用车配件</a>
			</h3>
			<!--热门-->
			<MainParts :message = "parts" :title = "title3"></MainParts>
			<!--隔断-->
			<div class="geduan"></div>
			<!--车门-->
			<MainParts :message = "carDoor" :title = "title4"></MainParts>
			<!--隔断-->
			<div class="geduan"></div>
			<!--照明系统-->
			<MainParts :message = "light" :title = "title5"></MainParts>
		</div>
		
		  
	</div>
</template>

<script>
	import MainNav from "./MainNav.vue"
	import MainBlock from "./MainBlock.vue"
	import MainParts from "./MainParts.vue"
	export default{
		data: function(){
			return{
				mes:"",
				hot:"",
				title1:"",
				title2:"",
				title3:"",
				title4:"",
				title5:"",
				tenance:"",
				parts:"",
				carDoor:"",
				light:"",
				showTypeCar:"爱车车型",
				chooses: "选择"
			}
		},
		mounted:function(){
			this.fetchData();
		},
		methods:{
			fetchData(){
				var _this = this;
				this.$http.get("src/json/data.json").then(function(res){
					_this.mes = res.data.mainNav;
					_this.hot = res.data.mainHot;
					_this.title1 = res.data.title.title1;
					_this.title2 = res.data.title.title2;
					_this.tenance = res.data.mainTenance;
					_this.parts = res.data.mainParts;
					_this.carDoor = res.data.mainCardoor;
					_this.title3 = res.data.title.title3;
					_this.title4 = res.data.title.title4;
					_this.title5 = res.data.title.title5;
					_this.light = res.data.mainLight;
				});
				
				if(sessionStorage.carData){
					this.showTypeCar = sessionStorage.carData;
					this.chooses = "修改"
				}else{
					this.showTypeCar = "爱车车型";
					this.chooses = "选择";
				}
			},
			checkCar(){
				this.$router.push({path:"/autolist"})
			}
		},
		components:{
			MainNav,
			MainBlock,
			MainParts
		}
	}
</script>

<style>
	@import url("../assets/css/index.css");
</style>